package com.itheima.service.db.imp;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.itheima.domain.db.User;
import com.itheima.domain.db.UserInfo;
import com.itheima.mapper.UserInfoMapper;
import com.itheima.service.db.UserInfoService;
import com.itheima.vo.PageBeanVo;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;

@DubboService
public class UserInfoServiceImp implements UserInfoService {
    @Autowired
    private UserInfoMapper userInfoMapper;
    @Override//添加userInfo
    public void save(UserInfo userInfo) {
        userInfoMapper.insert(userInfo);
    }

    @Override//修改添加userInfo
    public void update(UserInfo userInfo) {
        userInfoMapper.updateById(userInfo);
    }

    @Override//根据userid获取UserInfo
    public UserInfo findById(Long userId) {
        return userInfoMapper.selectById(userId);
    }

    @Override//查询所有用户详情并分页
    public PageBeanVo findUserInfoByPage(Integer pageNum, Integer pageSize) {
        //创建分页条件
        Page page=new Page(pageNum,pageSize);
        //调用mapper查询结果
        page=userInfoMapper.selectPage(page,null);
        //返回分页类
        return new PageBeanVo(pageNum,pageSize,page.getTotal(),page.getRecords());
    }
}
